package com.bestvike.stone.spring.client.ribbon;

import lombok.extern.apachecommons.CommonsLog;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;

/**
 * Created by 许崇雷 on 2019/2/15.
 */
@CommonsLog
public final class RibbonLoadBalancerClientEx extends RibbonLoadBalancerClient {
    public RibbonLoadBalancerClientEx(SpringClientFactory clientFactory) {
        super(clientFactory);
    }

    @Override
    public ServiceInstance choose(String serviceId) {
        final ServiceInstance service = super.choose(serviceId);
        log.info(String.format("==>LoadBalancer Using Host %s:%d for Service %s", service.getHost(), service.getPort(), serviceId));
        return service;
    }
}
